{{>header}}
library serializers;

import 'package:built_value/iso_8601_date_time_serializer.dart';
import 'package:built_value/serializer.dart';
import 'package:built_collection/built_collection.dart';
import 'package:built_value/json_object.dart';
import 'package:built_value/standard_json_plugin.dart';
{{#timeMachine}}import 'package:time_machine/time_machine.dart';
import 'package:{{pubName}}/local_date_serializer.dart';{{/timeMachine}}
{{#models}}{{#model}}import 'package:{{pubName}}/model/{{classFilename}}.dart';
{{/model}}{{/models}}
part 'serializers.g.dart';

@SerializersFor(const [{{#models}}{{#model}}
  {{classname}},{{/model}}{{/models}}
])
Serializers serializers = (_$serializers.toBuilder(){{#apiInfo}}{{#apis}}{{#serializers}}
      ..addBuilderFactory(
{{#isArray}}
        const FullType(Built{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}, [FullType({{baseType}})]),
        () => {{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}Builder<{{baseType}}>(),
{{/isArray}}
{{#isMap}}
        const FullType(BuiltMap, [FullType(String), FullType({{baseType}})]),
        () => MapBuilder<String, {{baseType}}>(),
{{/isMap}}
      ){{/serializers}}{{/apis}}{{/apiInfo}}{{#timeMachine}}
      ..add(const OffsetDateSerializer())
      ..add(const OffsetDateTimeSerializer()){{/timeMachine}}
      ..add(Iso8601DateTimeSerializer()))
    .build();

Serializers standardSerializers =
    (serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build();
